﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BolsaTrabajo.BusinessLogic;

public partial class wfEmpresa : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            try
            {
                txtRazonSocial.Focus();
            }
            catch (Exception ex)
            {

            }
            finally
            {
            }
        }
    }
    protected void btnRegistrar_Click(object sender, EventArgs e)
    {
        EmpresaLogic BLEmpresa = new EmpresaLogic();
        UsersInRolesLogic BLUsersInRoles = new UsersInRolesLogic();

        if (BLEmpresa.RegistrarEmpresa(Session["ApplicationId"].ToString(), 
                                      Session["UserID"].ToString(), 
                                      txtRUC.Text.Trim(), 
                                      txtRazonSocial.Text.Trim(),
                                      txtPersonaContacto.Text.Trim(),
                                      cbxDistrito.Value.ToString(),
                                      txtDireccion.Text.Trim(),
                                      txtCorreoElectronico.Text.Trim(),
                                      txtTelefono.Text.Trim(),
                                      txtPaginaWeb.Text.Trim(),
                                      Convert.ToInt32(cbxCategoria.Value),
                                      txtDescripcion.Text.Trim(),
                                      Session["UserID"].ToString(),
                                      DateTime.Now,
                                      true) == true)
        {
            BLUsersInRoles.Registrar(Session["UserID"].ToString(), "94310502-CB83-48A1-9932-ECCAAE1B2D86");

            ClientScript.RegisterStartupScript(this.GetType(), "Insercion", "<script>alert('Se Inserto un Registro de Empresa');</script>");
            Limpiar();
            Response.Redirect("wfMPEmpresa.aspx", true);
        }
        else
        {
            ClientScript.RegisterStartupScript(this.GetType(), "Insercion", "<script>alert('No Se Inserto un Registro de Empresa');</script>");
            Limpiar();
        }
    }

    private void Limpiar()
    {
        txtRUC.Value = null;
        txtRazonSocial.Value = null;
        txtPersonaContacto.Value = null;
        cbxDistrito.Value = null;
        txtDireccion.Value = null;
        txtCorreoElectronico.Value = null;
        txtTelefono.Value = null;
        txtPaginaWeb.Value = null;
        cbxCategoria.Value = null;
        txtDescripcion.Value = null;
    }
}